package com.rachel.materialdemo.common;

import android.view.ViewGroup;

import java.util.List;

/**
 * Created by zhengshaorui on 2017/8/23.
 */

public abstract class MultiItemBaseAdapter<T> extends RBaseAdapter<T> {

    private MultiItemTypeSupport<T> mMultiItemTypeSupport;
    public MultiItemBaseAdapter(List<T> list,MultiItemTypeSupport<T> multiItemTypeSupport) {
        super(-1, list);
        mMultiItemTypeSupport = multiItemTypeSupport;
    }

    @Override
    public int getItemViewType(int position) {
        return mMultiItemTypeSupport.getItemViewType(position,mDatas.get(position));
    }

    @Override
    public RBaseViewholder onCreateViewHolder(ViewGroup parent, int viewType) {
        int layoutid = mMultiItemTypeSupport.getLayoutId(viewType);
        RBaseViewholder viewholder = RBaseViewholder.getViewHolder(parent.getContext(),
                layoutid,parent);
        return viewholder;
    }

    @Override
    public int getItemCount() {
        return super.getItemCount();
    }
}
